package com.example;

import java.io.UnsupportedEncodingException;

public class StringTests {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String s1 = "";
        String s2 = new String();

        System.out.println(s1 == "");  // true，因为 s1 指向字符串池中的 ""
        System.out.println(s2 == "");  // false，因为 s2 是 new 出来的新对象
        System.out.println(s2.length());
        if (s2 != null && s2 != "") {
            System.out.println("hello");
        }

        String name = "abc";
        String s = new String(name.getBytes("ISO-8859-1"), "UTF-8");
        System.out.println(s);
        String s3 = new String(name.getBytes("UTF-8"), "UTF-8");
        System.out.println(s3);
    }
}
